#ifndef __UTIL__
#define __UTIL__

#include <cstddef>

#include "common.h"

void log(const LogLevel level, const char *fileName, const int line, const char *format, ...);

#define logDebug(format, ...) log(LOG_DEBUG, __FILE__, __LINE__, format "\n", ##__VA_ARGS__)

#define logInfo(format, ...) log(LOG_INFO, __FILE__, __LINE__, format "\n", ##__VA_ARGS__)

#define logWarn(format, ...) log(LOG_WARNING, __FILE__, __LINE__, format "\n", ##__VA_ARGS__)

#define logError(format, ...) log(LOG_ERROR, __FILE__, __LINE__, format "\n", ##__VA_ARGS__)

// 向上取整保证size是CHUNK_SIZE的倍数,
// 一是为了简化处理逻辑，另外aligned_alloc必须是对齐参数的倍数，否则会编译错误
size_t alignUp(const size_t size, const size_t alignmentSize = CHUNK_SIZE);

#endif  //__UTIL__